package com.py.credit.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.py.credit.dao.ShareLogDao;
import com.py.credit.entity.ShareLog;
import com.py.credit.service.ShareLogService;
import com.py.credit.utils.SQLBuilder;
import com.py.framework.core.common.Page;

@Service
public class ShareLogServiceImpl implements ShareLogService {

	@Autowired
	private ShareLogDao shareLogDao;

	@Override
	public List<ShareLog> getListForPage(String sortType, Page page) {

		return shareLogDao.getListForPage(sortType, page);
	}

	@Override
	public List<Map<String, Object>> getByConditionForPage(List<String> columns, String[] additionalColumns,
			String conditionStr, Page page) {
		List<String> conditions = SQLBuilder.createConditionSql(conditionStr);
		List<Map<String, Object>> batchLogs = shareLogDao.selectByConditionForPage(columns, additionalColumns,
				conditions, page);
		return batchLogs;
	}

	@Override
	public void add(int sortType, String searchCatalog, String ip, String username, String realname, long deptId,String content) {
		String id = UUID.randomUUID().toString();
		id = id.replaceAll("-", "");
		shareLogDao.add(id, sortType, searchCatalog, ip, username, realname, deptId, new Date(),content);
	}

	@Override
	public Integer getQueryCountByType(int type) {

		return shareLogDao.selectQueryCountByType(type);
	}

}
